package com.mycharx.springboothibernate.config;

import org.hibernate.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.hibernate5.HibernateTemplate;

import javax.persistence.EntityManagerFactory;

/**
 * The type Hibernate config.
 *
 * @author 张卜亢
 * @date 2020.03.29 00:25:29
 */
@Configuration
public class HibernateConfig {

    @Bean
    public HibernateTemplate hibernateTemplate(EntityManagerFactory entityManagerFactory) {
        return new HibernateTemplate(entityManagerFactory.unwrap(SessionFactory.class));
    }
}
